package ar.edu.itba.it.raytracer.engine

case class Ray(origin: Vector, direction: Vector) {
  def apply(t: Double) = origin + direction * t
  def tFor(point: Vector) = {
    var result: Option[Double] = None
    val v = point - origin
    if (direction.x != 0 && v.x / direction.x > 0) result = Some(v.x / direction.x)
    else if (direction.y != 0 && v.y / direction.y > 0) result = Some(v.y / direction.y)
    else if (direction.z != 0 && v.z / direction.z > 0) result = Some(v.z / direction.z)

    result
  }
}
